/*
 * All rights Reserved, Designed By DataDriver
 * Copyright:    DataDriver.Inc
 * Company:      Zhuo Wo Infomation Technology (ShangHai) CO.LTD
 */
package com.sun;

import com.sun.config.BeanConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

public class MainTest {


    /**
     * @Resource 是J2EE标准的，是按照名称进行组件的注入操作
     * @Autowired 是Spring下的、是按照类型进行组件的注入操作
     */

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BeanConfig.class);
        Object user = context.getBean("user");
        System.out.println(user);
        //通过环境变量取值
        ConfigurableEnvironment environment = context.getEnvironment();
        String property = environment.getProperty("user.pwd");
        System.out.println("密码:" + property);
        String[] names = context.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }
    }
}
